package com.mycompany.classes
{
  import mx.collections.ArrayCollection;
  import mx.core.Application;
  // This class forms the "model" of the MVC (
  // Model-View-Controller) architecture used in 
  // this application. Data that would otherwise
  // be found in the application or component 
  // files are centralized here.
 
  public class WizardModel{
    // This variable allows us to enforce having only one 
    // model object, and provides an entry point to 
    // access the data in the model.
    private static var instance:WizardModel;
   
    // This variable is a convenience obj allowing us to access the
    // main app ViewStack children to reset some components when
    // the "Cancel" button is clicked. It would be better to
    // replace this with an event, making even greater use of 
    // the MVC architecture.
    public static var app:Object;
    // These two variables are used to change the title of the
    // Panel enclosing the ViewStack with text indicating what 
    // step the user is currently on in the wizard.
    public static const wizardTitleBase:String = "Wizard";
    [Bindable] public static var wizardTitle:String =
wizardTitleBase;
    // These variables are used in the logic used to advance the
    // ViewStack using the navigation buttons, and to know when 
    // the buttons should be enabled. When on the first screen, 
    // the Back button should be disabled, and when on the last 
    // screen, the Next button should be disabled.
    [Bindable] public var wizardNumScreens:int = 0;
    [Bindable] public var wizardScreenIndex:int = 0;
    // This ArrayCollection is used to store the information
    // entered by the user as they progess through the wizard.
    [Bindable] public var enteredInformation:ArrayCollection = new
ArrayCollection();
    // This ArrayCollection simply feeds U.S. state information
    // into a ComboBox.
    [Bindable] public static var statesDP:ArrayCollection = new
ArrayCollection([
 {name: "ALABAMA", label: "AL"}, 
 {name: "ALASKA", label: "AK"},
 {name: "ARIZONA", label: "AZ"}, 
 {name: "ARKANSAS", label: "AR"},
 {name: "CALIFORNIA", label: "CA"}, 
 {name: "COLORADO", label: "CO"},
 {name: "CONNECTICUT", label: "CT"}, 
 {name: "DELAWARE", label: "DE"},
 {name: "DISTRICT OF COLUMBIA", label: "DC"}, 
 {name: "FLORIDA", label: "FL"},
 {name: "GEORGIA", label: "GA"}, 
 {name: "HAWAII", label: "HI"},
 {name: "IDAHO", label: "ID"}, 
 {name: "ILLINOIS", label: "IL"},
 {name: "INDIANA", label: "IN"}, 
 {name: "IOWA", label: "IA"},
 {name: "KANSAS", label: "KS"}, 
 {name: "KENTUCKY", label: "KY"},
 {name: "LOUISIANA", label: "LA"}, 
 {name: "MAINE", label: "ME"},
 {name: "MARYLAND", label: "MD"}, 
 {name: "MASSACHUSETTS", label: "MA"},
 {name: "MICHIGAN", label: "MI"}, 
 {name: "MINNESOTA", label: "MN"},
 {name: "MISSISSIPPI", label: "MS"}, 
 {name: "MISSOURI", label: "MO"},
 {name: "MONTANA", label: "MT"}, 
 {name: "NEBRASKA", label: "NE"},
 {name: "NEVADA", label: "NV"}, 
 {name: "NEW HAMPSHIRE", label: "NH"},
 {name: "NEW JERSEY", label: "NJ"}, 
 {name: "NEW MEXICO", label: "NM"},
 {name: "NEW YORK", label: "NY"}, 
 {name: "NORTH CAROLINA", label: "NC"},
 {name: "NORTH DAKOTA", label: "ND"}, 
 {name: "OHIO", label: "OH"},
 {name: "OKLAHOMA", label: "OK"},
 {name: "OREGON", label: "OR"},
 {name: "PENNSYLVANIA", label: "PA"}, 
 {name: "RHODE ISLAND", label: "RI"},
 {name: "SOUTH CAROLINA", label: "SC"}, 
 {name: "SOUTH DAKOTA", label: "SD"},
 {name: "TENNESSEE", label: "TN"}, 
 {name: "TEXAS", label: "TX"},
 {name: "UTAH", label: "UT"}, 
 {name: "VERMONT", label: "VT"},
 {name: "VIRGINIA", label: "VA"}, 
 {name: "WASHINGTON", label: "WA"},
 {name: "WEST VIRGINIA", label: "WV"}, 
 {name: "WISCONSIN", label: "WI"},
 {name: "WYOMING", label: "WY"}
    ]);
    // The constructor enables us to ensure only one 
    // instance of the
    // model exists at any time (singleton).
    public function WizardModel(){
      if( instance != null )
      {
        throw( new Error( "There can only be one instance of WizardModel." ) );
      }
    }
    // This method is used throughout to access non-static
    // variables of the model.
    public static function getInstance():WizardModel{
      if( instance == null ){
        instance = new WizardModel();
      }
      return instance;
    }
  }
}
